#include <string.h>
#include <stdio.h>
#include <stdlib.h>

int quan_sort(char * str, char * first, int number)
{
	if (NULL == str) {
	    exit(-1);
	}
	if (1 == number) {
		printf("%s\n", str);
	}
	for (int i = 0; i < number; ++i) {
		char tmp = first[0];
	    first[0] = first[i];
	    first[i] = tmp;
	    quan_sort(str, first+1, number-1);
	    first[i] = first[0];
	    first[0] = tmp;
	}
}

int zuhe_sort(char * str, char * first, int number)
{
	if (NULL == str) {
	    exit(-1);
	}
	if (1 == number) {
		printf("%s\n", str);
	}
	for (int i = 0; i < number; ++i) {
		if (0 != i && first[0] == first[i]) {
			continue;
		}
		char tmp = first[0];
	    first[0] = first[i];
	    first[i] = tmp;
	    quan_sort(str, first+i, number-i);
	    first[i] = first[0];
	    first[0] = tmp;
	}
}

/*
int main()
{
	char str[] = "aabb";
	printf("%d\n", sizeof(str));
	quan_sort(str, str, 4);
	printf("\n\n");
	zuhe_sort(str, str, 4);
}
*/
